<?php
require_once 'Connection.php';

/**
 * class RssReader
 *
 * title, description, link, pubdate
 *
 */
class RssReader {
	
	/**
	 * Get Rss Content
	 *
	 * @return array of rss obj 
	 */
	public static function GetContent($url)
	{
		$rssItems = array();
		
		$xmlDoc = new DOMDocument();
		if (!$xmlDoc->load($url)) return $rssItems;

		//get and output "<item>" elements
		$items = $xmlDoc->getElementsByTagName('item');
		foreach ($items as $item)
		{
			$rssItem = array();
			$rssItem['title'] = $item->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
			$rssItem['link'] = $item->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
			$rssItem['description'] = $item->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;
			$rssItem['pubDate'] = $item->getElementsByTagName('pubDate')->item(0)->childNodes->item(0)->nodeValue;
			array_push($rssItems, $rssItem);
		}
		return $rssItems;	
	}
	
}
?>